//管理项目位置地址数据相关
import {defineStore} from "pinia";
import {ref} from "vue";
import {getAllLocationAPI} from "@/apis/userLocation.ts";

export const useLocationStore=defineStore('location',()=>{
interface Location {
    id: number,
    userId: number,
    projectId: number,
    locationAddress: string,
    description: string,
    }


        //1.定义所有location数据的state
        const locationInfo=ref<Location>({id: 0,userId: 0,projectId: 0,locationAddress: '',description: ''});



        //2.定义获取接口数据的action函数
        const getLocationInfo=async (current:number,pageSize:number)=>{
            const res=await getAllLocationAPI(current,pageSize);
            locationInfo.value=res.data;
        }



        //3.以对象的格式把state和action return
        return {
            locationInfo,getLocationInfo
        }
    },
    // pinia持久化配置，存入ls，true
    // {
    //     persist:true,
    // }
    )



